
package psim;

import gui.Gui;
import java.lang.reflect.Method;
import java.util.ArrayList;
import javax.swing.SwingUtilities;

/**
 * Hlavni trida programu Ptcsim
 * @author Tomas Drimal
 */
public class Main {
    // promenna udrzujici hodnotu poctu cyklu
    public static long cykly = 0;
    // instance tridy castic
    public static PtcsBase particles;
//    pocet procesoru
    public static int nrOfCPU = 1;
    public static double dt = 100; //krok casu v sekundach
//    rozmery simulovaneho prostoru
    public static double scale_x ;
    public static double scale_y ;
    // pole historie vykreslenych castic
    public static ArrayList<int[]> PtcsHist = new ArrayList<int[]>();
    //globalni promenna, ktera udrzuje informaci, jestli simulovat, nebo ne
    public static boolean simulation = false;
    //boolean promenna, ktera rika, jestli se ma vymazat platno
    public static boolean clrCanvas = false;
//    Rozmery simulacniho zobrazovaneho prostoru
    public static int CLIENT_WIDTH_PX = 600;
    public static int CLIENT_HEIGHT_PX = 600;
    // jestli se maji castice odrazet od sten
    public static boolean bound = true;
    // jestli zobrazovat stopy castic
    public static boolean VTraces = true;
    // jestli smazat stopy castic
    public static boolean clrTraces = false;
//    Pocet kroku, ktere se maji provest
    public static long nrOfSteps = -1;
//    jmeno metody, ktera se pouziva pro prepocet rychlosti castic
    public static String mthdName ="";
//    seznam vsech dostupnych metod pro prepocet rychlosti castic
    public static Method[] cptMet = PtcCompute.class.getDeclaredMethods();

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        //zjisteni poctu jader procesoru
        Runtime runtime = Runtime.getRuntime();
        nrOfCPU = runtime.availableProcessors();
        nrOfCPU = 3;

        if (nrOfCPU == 1) {
            particles = new PtcsSigle();
        } else {
            particles = new PtcsMulti(nrOfCPU);
        }
//      vyrvoreni GUI
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                Gui.createAndShowGUI();
            }
        });
//        spusteni simulace
            particles.startSim();
        

    }
}
